<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>设置</title>
		<link href="css/public.css" rel="stylesheet" type="text/css">
		<link href="css/set.css" rel="stylesheet" type="text/css">
	</head>
	<body>
		<?php 
			include './includes/header.inc.php';
		?>
		<div id="set">
			<div id="set_top">
				<div>个人资料</div>
			</div>
			<?php
				//准备sql
				$sql = "select id,username,email,sex,age,xueli,pic,rtime,rip,qx from user where id={$_SESSION['id']}";
				//执行sql
				$res = mysqli_query($link, $sql);
				//判断执行结果
				if($res && mysqli_num_rows($res)){
					$uinfo = mysqli_fetch_assoc($res);
				}
			?>
			<div id="set_content">
				<form method="post" action="doset.php" enctype="multipart/form-data">
					<input type="hidden" name="pic" value="<?php echo $uinfo['pic']?>">
					<div class="set_content1">
						<div class="set_content2">用户名</div>
						<div class="set_content3"><?php echo $uinfo['username']?></div>
					</div>
					<div class="set_content1">
						<div class="set_content2">头像</div>
						<div class="set_content3">
							<input type="file" name="pic">
							<?php
								if($uinfo['pic'] == 'default.jpg'){
							?>
									<img src="../images/<?php echo $uinfo['pic']?>">
							<?php
								}else{
							?>
									<img src="../images/s_<?php echo $uinfo['pic']?>">
							<?php
								}
							?>
						</div>
					</div>
					<div class="set_content1">
						<div class="set_content2">邮箱</div>
						<div class="set_content3">
							<input type="email" name="email" value="<?php echo $uinfo['email']?>">
						</div>
						
					</div>
					<div class="set_content1">
						<div class="set_content2">性别</div>
						<div class="set_content3">
							<select name="sex">
								<?php
									//定义一个数组
									$sexarr = array(1 => '男',2 => '女',3 => '保密');
									foreach($sexarr as $k => $v){
										echo '<option value="'.$k.'"'.($uinfo['sex'] == $k ? 'selected' : '').'>'.$v.'</option>';
									}
								?>
							</select>
						</div>
						
					</div>
					<div class="set_content1">
						<div class="set_content2">年龄</div>
						<div class="set_content3">
							<input type="text" name="age" value="<?php echo $uinfo['age']?>">
						</div>
						
					</div>
					<div class="set_content1">
						<div class="set_content2">学历</div>
						<div class="set_content3">
							<select name="xueli">
								<?php
									//定义一个数组
									$xueliarr = array(1 => '小学','初中','高中','大学','烟酒生','保密');
									foreach($xueliarr as $k => $v){
										echo '<option value="'.$k.'"'.($uinfo['xueli'] == $k ? 'selected' : '').'>'.$v.'</option>';
									}
								?>
							</select>
						</div>
						
					</div>
					<div class="set_content1">
						<div class="set_content2">注册时间</div>
						<div class="set_content3"><?php echo date('Y-m-d H:i:s',$uinfo['rtime'])?></div>
					</div>
					<div class="set_content1">
						<div class="set_content2">注册IP</div>
						<div class="set_content3"><?php echo long2ip($uinfo['rip'])?></div>
					</div>
					<div class="set_content1">
						<div class="set_content2">权限</div>
						<div class="set_content3">
							<?php 
								if($uinfo['qx'] == 1){
									echo '普通会员';
								}else{
									echo '管理员';
								}
							?>
						</div>
					</div>
					<div>
						<div class="set_content2"></div>
						<div class="set_content3">
							<input type="submit" value="保存">
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="clear"></div>
		<?php 
			//释放结果集
			mysqli_free_result($res);
			include './includes/footer.inc.php';
		?>
	</body>
</html>